/*************************************************************************  
 *   This file is part of UBBMPSREADER.
 *
 *   UBBMPSREADER is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   UBBMPSREADER is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with UBBMPSREADER.  If not, see <http://www.gnu.org/licenses/>. 
 *************************************************************************/

package cs.ubbcluj.ro.mps.data.interfaces;

import java.util.Map;
import java.util.Set;

import cs.ubbcluj.ro.datatypes.implementations.SparseMatrix;
import cs.ubbcluj.ro.datatypes.implementations.SparseVector;
import cs.ubbcluj.ro.datatypes.interfaces.Matrix;
import cs.ubbcluj.ro.datatypes.interfaces.Vector;
import cs.ubbcluj.ro.mps.data.BoundsType;
import cs.ubbcluj.ro.mps.data.ConstrainImpl;

/**
 * Represents an MPS file with the parsed data
 * 
 * @author avadas
 * @version 1.0
 */
public interface Mps {
    /**
     * Sets the name of the MPS file
     * 
     * @param name
     *            the name of the MPS file
     */
    void setName(final String name);

    /**
     * Returns the name of the MPS file
     * 
     * @return the name of the MPS file
     */
    String getName();

    /**
     * Adds a constrain (an element from the ROW section)
     * 
     * @param constrain
     *            the constrain to add
     */
    void addConstrain(final ConstrainImpl constrain);

    /**
     * Adds a variable and its' coefficient to a given constrain
     * 
     * @param name
     *            the name of the constrain
     * @param variableName
     *            the variableName
     * @param coeficient
     *            the coefficient
     * @throws Exception
     */
    void addVariableToConstrain(final String name, final String variableName,
	    final double coeficient) throws Exception;

    /**
     * Returns the elements of the ROW section
     * 
     * @return all constrains of this MPS file
     */
    Map<String, Constrain> getConstrains();

    /**
     * Adds a constrian to RHS (represents b)
     * 
     * @param name
     *            the name of the constrain
     * @param rhsName
     *            the rhs name (in most cases b)
     * @param value
     *            the value of the constrain
     */
    void addConstrainToRhs(final String name, final String rhsName,
	    final double value);

    /**
     * Adds a bound
     * 
     * @param boundName
     *            the name of the bound
     * @param variableName
     *            the name of the variable
     * @param boundType
     *            the type of the bound
     * @param boundValue
     *            the value of the bound
     */
    public int countLGConstrains();
    
    void addVariableBound(String boundName, String variableName,
	    BoundsType boundType, Double boundValue);

    
  
    public int getNumberOfVariables();

    /**
     * Returns the number of constrains - 1 (target constrain) (constrain =
     * equation)
     * 
     * @return the number of constrains
     */
    
    public Set<String> getVariableIndex();
    
    public Map<String, Map<String, Double>> getRhs();
    
    public Map<String, Constrain> getTargetFunction();
    
    public Map<String, Double> getLowerBound();
    
    public Map<String, Double> getUpperBound();
    
    public int getNumberOfConstrains();

    /**
     * 
     * @param constrainName
     *            the name of the constrain
     * @param rangeName
     *            the name of the range
     * @param value
     *            the value of the range
     */
    void addConstrainToRanges(String constrainName, String rangeName,
	    double value);

    /**
     * Based on http://www.emse.fr/~mazier/cplex/doc/reffileformatscplex/
     * reffileformatscplex8.html
     * 
     * @return the lower limitsof constrains
     */
    
    Matrix getCoefficients();
	
	Vector getRightHandSideValues();
	
	public Vector getTargetCoefficients();
	
	public Vector getLowerBounds();
	
	public Vector getUpperBounds();
}
